// TOWN DIALOGUE SCRIPT
//    Town 85: Distant Hut

begintalkscript;

variables;

short i,j,k,r1,choice;

// Ernest

begintalknode;
	tag = 40;
	state = -1;
	nextstate = 1;
	question = "Ernest";
	text1 = "You meet a small, heavily built mage with gray hair and a potbelly. His hair is unkempt. He clearly wasn't expecting visitors. Or he just doesn't care.";
	text2 = "He pours you some tea. _I am Ernest. Welcome to my humble abode. I am glad someone is finally able to visit me._";
	text5 = "Ernest smiles. _I am glad you are able to visit me. It is good to see a fresh face. I seldom receive visitors._ He pours you more tea. He makes it from his own herbs. It is unpleasant.";
	action = INTRO;

begintalknode;
	state = 1;
	nextstate = 2;
	question = "_You live here alone?_";
	text1 = "_Yes. It is a pleasure to meet an Avernite at last. Welcome to my home._";

begintalknode;
	state = 2;
	nextstate = 3;
	question = "_What makes you think I'm from Avernum?_";
	text1 = "He holds his hands open as a peaceful gesture. _Well, the paleness of your skin immediately marks you as an Avernite. Don't worry about it. You aren't likely to meet much hostility. Around Krizsan, anyway._";

begintalknode;
	state = 3;
	nextstate = 4;
	question = "_Why aren't the people around here hostile to us?_";
	text1 = "_Well, people are really busy worrying about the slimes, and they don't believe your lot is powerful enough to create them. So you're safe around here. The other provinces are a different story._";
	text3 = "_Well, people are really busy worrying about whether the slimes will return, and they don't believe your lot is powerful enough to create them. So you're safe around here. The other provinces are a different story._";
	action = DEP_ON_SDF 307 3 0;

begintalknode;
	state = 4;
	nextstate = -1;
	question = "_What are attitudes like up north?_";
	text1 = "_I hear up north that they think the monster plagues were caused by your people. Be careful if you go up there._";

begintalknode;
	state = 4;
	nextstate = -1;
	question = "_Avernum has many powerful mages, so I suspect that we may be powerful enough to have created this plague._";
	text1 = "_Agreed. I know you are powerful enough. Did you create them? Or not? I couldn't care less. Avernites are as good to test my teleporters as anybody._";

begintalknode;
	state = 4;
	nextstate = -1;
	condition = gf(307,3) == 0;
	question = "_What do you know about the slimes?_";
	text1 = "_About a year ago, giant slimes started appearing everywhere. They eat everything, attack everyone, and nobody can figure out where they come from._";
	text2 = "_I hear the other provinces are having similar problems, but I don't get much news. I spend all my time here, researching._";

begintalknode;
	state = 1;
	nextstate = 5;
	question = "_Why do you live out in the wilderness?_";
	text1 = "_This little warren out in the remote reaches is where I do my teleportation research. No slimes ever come here, so it's perfect._";
	text3 = "_This little warren out in the remote reaches is where I do my teleportation research. It is so far out that not even the slimes came here. When there were slimes, that is._";
	action = DEP_ON_SDF 307 3 0;

begintalknode;
	state = 5;
	nextstate = 6;
	question = "_Tell me about your research._";
	text1 = "He smiles wryly. _Seems like everyone's doing teleportation research these days, doesn't it? Well, my devices actually work. I'll even let you test them, for a cost._";

begintalknode;
	state = 6;
	nextstate = 7;
	question = "_What's the cost to use your teleporter?_";
	text1 = "_I've made teleporters that go to the five biggest cities in Valorim. A week's travel, in an instant. Generally somewhat safe. And only 50 gold for a chance to try one of them._ He chuckles.";
	text2 = "_Quite a bargain, eh? Let me know if you want to purchase a ticket. You can wander around and see my work all you want. Just don't touch the crystal pillar._";
	action = SET_SDF 85 11 1;

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(85,11) == 1;
	question = "_May I buy one of your teleporter tickets?_ (Pay 50 coins.)";
	text1 = "You pay him. _Excellent! The portals are around here somewhere. They will allow you to enter them now. Help yourself! Oh, and don't play with my crystal pillar._";
	text3 = "He shakes his head. _I know, I know. I should be happy for volunteers. But research is expensive. I have to insist on 50 gold. Oh, and don't play with the crystal pillar._";
	text5 = "_You currently have one. Lucky you._";
	code =
		cs();
		if (gf(85,8) > 0)
			as(5);
			else if (coins_amount() < 50)
				as(3);
				else {
					change_coins(-50);
					sf(85,8,1);
					as(1);
					}
	break;
	
begintalknode;
	state = 7;
	nextstate = -1;
	question = "_The pillar?_";
	text1 = "_My portals are powered by a powerful pillar of magically treated crystal. If you come across it, don't tinker with it. That would be bad. Very bad._";

begintalknode;
	state = 1;
	nextstate = -1;
	question = "_How did you know that I was coming?_";
	text1 = "_Thanks to the power of teleportation, I frequently speak to people from all over Krizsan province. Some of them have told me certain rumors regarding a group of traveling Avernites._";

begintalknode;
	state = 6;
	nextstate = -1;
	question = "_What did you use to do research?_";
	text1 = "_I have a small library here. Small, but powerful. You may wander my home if you wish, but please don't take any of my books. Some of them are very delicate and powerful._ (You take note of this.)";
	action = SET_SDF 85 9 1;

begintalknode;
	state = 7;
	nextstate = 8;
	question = "_Where do the teleporters lead?_";
	text1 = "_To the five major cities of Valorim. Well, once there were six. Now just five._";

begintalknode;
	state = 8;
	nextstate = -1;
	question = "_Tell me about the cities._";
	text1 = "_Oh, I never go there. I just send people there._";

begintalknode;
	state = 8;
	nextstate = -1;
	question = "_What happened to the sixth?_";
	text1 = "_Oh, the Keep of Tinraya was destroyed by monsters._";

begintalknode;
	state = 1;
	nextstate = -1;
	condition = gf(85,12) == 1;
	question = "_I'm sorry that I stole your book._";
	text1 = "_You should be. Keep it. I don't need it anymore. But be careful when you use my portals. You just might get an unpleasant surprise._";
	code =
		sf(85,12,2);
	break;
	
begintalknode;
	state = 1;
	nextstate = -1;
	condition = 1;
	question = "_I'll be going now._";
	text1 = "_I hope you stop by again._";
	text2 = "_Since you have a ticket, you can enter my portals. They are to the north._";
	text3 = "_Since you don't have a ticket, I wish you a safe journey. On foot._";
	action = END_TALK;
	code =
		if (gf(85,8) > 0)
			rs(3);
			else rs(2);
	break;
	